module CanCamel
  module Base
    # don't delegate all, because lint_node designed to be run on same instances of linter
    delegate :lint, :lint!, to: :new_linter

    # returns hash with some return params or nil.
    # @param user [User] user respond to GROUP_METHOD
    # @param action [Symbol] symbol relied to action node name
    # @param subject [Symbol] symbol relied to subject node name
    # @return [Hash, nil] hash with specific params or nil
    def can?(user, *path, **args)
      Cache[[user.send(GROUP_METHOD).to_sym, *path]]
        .try(:can?, user: user, **args)
    end

    private

    def new_linter
      CanCamel::Linter.new
    end
  end
end
